<template>
	<view class="home">
		<view class="home_search">
			<view class="home_search_top">
				<view class="flex_1 home_search_type">全部</view>
				<input type="text" class="flex_1 home_search_name" v-model="searchForm.name" placeholder="请输入商户名称" />
			</view>
			<view class="home_search_bottom">
				<view class="home_search_bottom_icon u-flex">
					<u-icon name="e60a" size="35" color="#6891FB" custom-prefix="iconfont"></u-icon>
					<view class="u-m-l-10">时间</view>
				</view>
				<view class="home_search_bottom_time">
					<view class="" @click="onStartDate">{{searchForm.start_date || '选择开始日期'}}</view>
					<view class="u-m-l-25 u-m-r-25">-</view>
					<view class="" @click="onEndDate">{{searchForm.end_date || '选择结束日期'}}</view>
				</view>
				<view class="home_search_btn" @click="onSearch">
					<u-icon name="e61e" size="40" color="#ffffff" custom-prefix="iconfont"></u-icon>
				</view>

			</view>
			<u-picker mode="time" v-model="showTime" :params="timeParams" @confirm="onTimeConfirm" />
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				timeParams: {
					year: true,
					month: true,
					day: true,
				},
				timeType: '',
				showTime: false,
				searchForm: {
					name: '',
					start_date: '',
					end_date: '',

				}
			};
		},

		onLoad() {

		},
		onShow() {

		},
		methods: {
			onSearch() {
				this.$emit('searchClick', this.searchForm)
			},
			onShowTime() {
				this.showTime = true
			},
			onEndDate(val) {
				this.onShowTime()
				this.timeType = 'end_date'
			},
			onTimeConfirm(val) {

				let {
					year,
					month,
					day
				} = val
				this.searchForm[this.timeType] = `${year}-${month}-${day}`
			},
			onStartDate() {
				this.onShowTime()
				this.timeType = 'start_date'
			},
		}
	};
</script>
<style>
	page {
		background-color: #f5f5f5;
		color: rgba(0, 0, 0, .6);
		;
	}
</style>
<style lang="scss" scoped>
	.home {
		.flex_1 {
			flex: 1;
		}



		.home_search {
			border-radius: 16rpx;
			padding: 26rpx;
			width: 100%;

			background-color: #ffffff;

			.home_search_top {
				display: flex;
				border-bottom: 1px solid rgba(0, 0, 0, .1);
				height: 60rpx;

				.home_search_type {
					text-align: center;
					height: 100%;
					line-height: 60rpx;
				}

				.home_search_name {
					text-align: center;
					height: 100%;
					border-left: 1rpx solid rgba(0, 0, 0, .1);
				}
			}

			.home_search_btn {
				display: flex;
				justify-content: center;
				align-items: center;
				flex: 1;
				height: 60rpx;
				margin-left: 15rpx;
				background-color: #6177ED;
			}

			.home_search_bottom {
				display: flex;
				margin-top: 30rpx;

				.home_search_bottom_time {
					margin-left: 10rpx;
					border: 1rpx solid rgba(0, 0, 0, .1);
					padding: 8rpx 20rpx;
					display: flex;
					font-size: 29rpx;
					align-items: center;
				}
			}
		}

	}
</style>
